/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.tesam.gedeon.controller;

import com.tesam.gedeon.entity.Country;
import com.tesam.gedeon.entity.Department;
import com.tesam.gedeon.service.DepartmentService;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 *
 * @author Sistema
 */
@Controller
public class DepartmentController {
    
    @Autowired
    SystemUserController system ;
    @Autowired
    DepartmentService departmentService ;
    Country country = new Country();
    
    @RequestMapping(value = "/department/bycountry")
    public ModelAndView getDepartmentByCountry(@ModelAttribute("Department") Department department , 
                                    HttpServletRequest request){
        ModelAndView mv = new ModelAndView("/department/bycountry");
        
        country.setCode(request.getParameter("codeCountry").toString());
        department.setCountry(country);
        
        mv.addObject("department", departmentService.getListByCountry(department));
        return mv ; 
    }
    
}
